package xframe.init;

import java.io.*;
import java.util.*;
import xframe.common.StartClass;

public class StaticValue
    implements StartClass
{

    public StaticValue()
    {
    }

    public void service(HashMap param)
    {
        File variableDir = new File((String)param.get("GLOBAL_STATIC_VARIABLE_ROOT"));
        File variableFile[] = variableDir.listFiles();
        for(int i = 0; i < variableFile.length; i++)
            if(variableFile[i].getName().toLowerCase().endsWith(".static_var"))
            {
                Properties props = new Properties();
                InputStream is = null;
                try
                {
                    is = new FileInputStream(variableFile[i].getAbsolutePath());
                    props.load(is);
                    is.close();
                    String variableId;
                    String variableValue;
                    for(Enumeration propKeys = props.keys(); propKeys.hasMoreElements(); GB_V_HM.put(variableId, variableValue))
                    {
                        variableId = (String)propKeys.nextElement();
                        variableValue = props.getProperty(variableId);
                        int inx = variableFile[i].getName().indexOf(".");
                        variableId = variableFile[i].getName().substring(0, inx) + "." + variableId;
                    }

                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }

    }

    public static String get(String key)
    {
        return (String)GB_V_HM.get(key);
    }

    public static HashMap GB_V_HM = new HashMap();

}
